home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Include / FWStyle.h < prev    next >
Encoding:
Text File  |  1994-04-21  |  4.6 KB  |  177 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWStyle.h
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWSTYLE_H
  13. #define FWSTYLE_H
  14.  
  15. // ----- Foundation Includes -----
  16.  
  17. #ifndef FWSTDDEF_H
  18. #include <FWStdDef.h>
  19. #endif
  20.  
  21. #ifndef FWGRDEF_H
  22. #include "FWGrDef.h"
  23. #endif
  24.  
  25. #ifndef FWGROBJ_H
  26. #include "FWGrObj.h"
  27. #endif
  28.  
  29. #ifndef FWGConst_H
  30. #include "FWGConst.h"
  31. #endif
  32.  
  33. #ifndef FWPAT_H
  34. #include "FWPat.h"
  35. #endif
  36.  
  37. // ----- OpenDoc Includes -----
  38.  
  39. #ifndef _PLFMTYPE_
  40. #include <PltmType.h>
  41. #endif
  42.  
  43. #ifndef _XMPTYPES_
  44. #include <XMPTypes.h>
  45. #endif
  46.  
  47. // ----- Fundation Includes -----
  48.  
  49. #ifndef FWSTRING_H
  50. #include "FWString.h"
  51. #endif
  52.  
  53. //========================================================================================
  54. //    •• Forward Class Declarations
  55. //========================================================================================
  56.  
  57. class FW_CStyleRep;
  58. class FW_CGraphicContext;
  59.  
  60. //========================================================================================
  61. //    •• CLASS FW_CStyle
  62. //========================================================================================
  63.  
  64. class FW_CStyle : public FW_CGraphicObjectPtr
  65. {
  66. public:
  67.     FW_CStyle();
  68.     FW_CStyle(XMPCoordinate penSize, const FW_CPattern& pattern = FW_kBlackPat);
  69.     FW_CStyle(const FW_CDynamicString& fontName, FW_FontStyle fontStyle, XMPCoordinate fontSize);
  70.     FW_CStyle(XMPCoordinate penSize, const FW_CPattern& pattern,
  71.             const FW_CDynamicString& fontName, FW_FontStyle fontStyle, XMPCoordinate fontSize);
  72.     
  73.     FW_CStyle(const FW_CStyle& other);
  74.     FW_CStyle(FW_CStyleRep* rep);
  75.             
  76.     FW_CStyle& operator=(const FW_CStyle& other);        
  77.     FW_CStyleRep* operator->() const;
  78. };
  79.  
  80. //----------------------------------------------------------------------------------------
  81. //    • FW_CStyle::operator->
  82. //----------------------------------------------------------------------------------------
  83. inline FW_CStyleRep* FW_CStyle::operator->() const
  84. {
  85.     return (FW_CStyleRep*)GetRep();
  86. }
  87.  
  88. //==============================================================================
  89. //    •• class FW_CStyleRep
  90. //==============================================================================
  91.  
  92. class FW_CStyleRep : public FW_CGraphicObjectRep
  93. {
  94.     friend class FW_CStyle;
  95.     
  96. //------------------------------------------------------------------------------
  97. //    • Constructors/Destructors
  98. //
  99. private:
  100.     FW_CStyleRep();
  101.     FW_CStyleRep(XMPCoordinate penSize, const FW_CPattern& pattern);
  102.     FW_CStyleRep(const FW_CDynamicString& fontName, FW_FontStyle fontStyle, XMPCoordinate fontSize);
  103.     FW_CStyleRep(XMPCoordinate penSize, const FW_CPattern& pattern,
  104.                  const FW_CDynamicString& fontName, FW_FontStyle fontStyle, XMPCoordinate fontSize);
  105.     
  106.     virtual ~FW_CStyleRep();
  107.     
  108. //------------------------------------------------------------------------------
  109. //    • Inherited API
  110. //
  111. public:
  112.     virtual void            Flatten(FW_CWritableStream& stream);
  113.     virtual void            Unflatten(FW_CReadableStream& stream);
  114.     
  115. //------------------------------------------------------------------------------
  116. //    • New API
  117. //
  118. public:
  119.     void            SetPenSize(XMPCoordinate penSize);
  120.     XMPCoordinate     GetPenSize() const
  121.                         {return fPenSize;}
  122.  
  123.     void            SetFontSize(XMPCoordinate fontSize);
  124.     XMPCoordinate     GetFontSize() const
  125.                         {return fFontSize;}
  126.  
  127.     void            SetFontStyle(FW_FontStyle fontStyle);
  128.     FW_FontStyle     GetFontStyle() const
  129.                         {return fFontStyle;}
  130.  
  131.     void            SetFontName(const FW_CDynamicString& fontName);
  132.     void            GetFontName(FW_CDynamicString& fontName) const
  133.                             {fontName = fFontName;}
  134.  
  135.     void            SetPattern(const FW_CPattern& pattern);
  136.     void             GetPattern(FW_CPattern& pattern) const
  137.                         {pattern = fPattern;}
  138.     
  139.     FW_CStyle        Copy() const;
  140.  
  141. #ifdef FW_BUILD_MAC
  142.     void            GetMacFontInfo(short& textFont, Style& textFace, XMPCoordinate& textSize) const;
  143. #endif
  144.  
  145. #ifdef FW_BUILD_MAC
  146. private:
  147.     void            CheckMacCache();    
  148. #endif
  149.  
  150. //------------------------------------------------------------------------------
  151. //    • Public but for internal use only
  152. //
  153. public:
  154.     FW_SPlatformPoint    AsPlatformSize(FW_CGraphicContext* graphicContext, XMPCoordinate aSize);
  155.     void                SelectInGC(FW_CGraphicContext* gc, FW_ShapeCategory shapeCategory);
  156.  
  157.  
  158. //------------------------------------------------------------------------------
  159. //    • Data Members
  160. //
  161. private:
  162.     XMPCoordinate        fPenSize;
  163.     FW_CPattern            fPattern;
  164.     
  165.     FW_CDynamicString    fFontName;
  166.     FW_FontStyle        fFontStyle;
  167.     XMPCoordinate        fFontSize;
  168.  
  169. #ifdef FW_BUILD_MAC
  170.     FW_Boolean            fMacCacheValid;
  171.     short                fMacTextFont;
  172.     Style                fMacTextFace;
  173. #endif
  174. };
  175.  
  176. #endif
  177.